extends Node2D

@onready var tilemap = $TileMap

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	random_tile(18,1,5)
	#random_tile(5,2,1)
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func random_tile(x: int , y:int ,randomnum:int):
	tilemap.clear_layer(1)
	var bg1_cells = tilemap.get_used_cells(0)
	var ran = RandomNumberGenerator.new()
	for cell_pos in bg1_cells:
		var num = ran.randi_range(0,100)
		if num<= randomnum:
			tilemap.set_cell(1,cell_pos,0,Vector2i(x,y))
		
	pass
